#include <Windows.h>
#include <sstream>
#include "memoryID.hpp"

bool MemoryID::GetInfo( void )
{
	// Get amount of RAM
	MEMORYSTATUS stat;
	GlobalMemoryStatus (&stat);
	m_uRAMTotal				= (unsigned int)(stat.dwTotalPhys/(1024*1024))+1;
	m_uRAMFree				= (unsigned int)(stat.dwAvailPhys/(1024*1024))+1;
	m_uPageFileTotal		= (unsigned int)(stat.dwTotalPageFile/(1024*1024))+1;
	m_uPageFileFree			= (unsigned int)(stat.dwAvailPageFile/(1024*1024))+1;
	m_uVirtualTotal			= (unsigned int)(stat.dwTotalVirtual/(1024*1024))+1;
	return true;
}

std::string MemoryID::Print( void )
{
	std::ostringstream out("\n\n");
	out << "\nTotal Physical:           " << m_uRAMTotal << " MB";
	out << "\nFree Physical:            " << m_uRAMFree << " MB";
	out << "\nTotal Pagefile:           " << m_uPageFileTotal << " MB";
	out << "\nFree Pagefile:            " << m_uPageFileFree << " MB";
	//out << m_uVirtualTotal << "=" << (m_uPageFileTotal+m_uRAMTotal);
	return out.str();
}
